<?php
namespace app\modules\adminapi\controllers;

use fate\http\Request;
use app\models\User;

class ListuserController extends \app\modules\adminapi\ForceLoginPure {

    public function run() {
        $req = Request::getInstance();

        $p = $req->getQueryString('page');
        $pageSize = 10;
        if(!is_numeric($p)) {
            $p = 1;
        }

        // user center req
        $where = '1=1';
        $user = new User();
        $total = $user->count($where);
        $ret = $user->getListByPage(
            'id,gender,user_name,email,avatar,role,birthday,reg_time,status',
            $where, $p, $pageSize);

        $this->ajaxReturn([
            'page_size' => $pageSize,
            'current' => $p,
            'total' => $total,
            'data' => $ret
        ]);
    }

}
